package com.huatech.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.huatech.common.util.StringUtil;
import com.huatech.domain.UserDetail;
import com.huatech.mapper.UserDetailMapper;
import com.huatech.service.UserInfoService;

@Service
public class UserInfoServiceImpl implements UserInfoService {

	 @Autowired UserDetailMapper  userDetailMapper;
	 
	@Override
	public UserDetail findByUserName(String username) {
		Map<String, Object> params = new HashMap<>();
    	if(StringUtil.isPhone(username)){
    		params.put("phone", username);
    	}else if(StringUtil.isMail(username)){
    		params.put("email", username);
    	}else{
    		params.put("loginName", username);
    	}
    	return userDetailMapper.findByLoginName(params);
	}

}
